/*
 * FileReader.h
 *
 *  Created on: Jan 23, 2012
 *      Author: Ivan
 */

#ifndef FILEREADER_H_
#define FILEREADER_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
typedef struct Instructionlist ILIST;
typedef struct InstructionEntry IENTRY;


 struct Instructionlist
{
    unsigned int  Length; /* Length of the list*/
    /*unsigned int NumberInstructions:*/
    IENTRY *First; /* pointer to the first entry, or NULL */
    IENTRY *Last; /* pointer to the last entry, or NULL  */
};

 struct InstructionEntry
{
    ILIST  *List;   /* pointer to the list which this entry belongs to */
    IENTRY *Next;   /* pointer to the next entry, or NULL */
    IENTRY *Prev;   /* pointer to the previous entry, or NULL */
    int instruction;  /* Instruction */
    /* what the hell is this?
    DECODED *DeInstruction;
    */
};





	/* allocate a new instruction list */
	ILIST *NewInstructionList();

	/* delete a instruction list (and all entries) */
	void DeleteInstructionList(ILIST *l);

	/* insert an instruction into a list */
	void AppendInstruction(ILIST *l, int z);

/*add eof*/
	ILIST * ReadBinFile (char * fname);
	ILIST * ReadBinFileIvanStyle (char * fname);
	ILIST * ReadBinFileIvanStyleInt (char * fname);
	int switchorder(int x);


	void convertelf(char *filename);
	/*this function takes the user inputted .elf file, then converts it to a binary file*/

	void convertHex(char *filename);  /*this function takes the user inputted .hex file, then converts it to a binary file*/


	void Test_Instruction(ILIST *h);


/*bin*/

/*return pointer to this*/

#endif /* FILEREADER_H_ */
